package com.runda.entity;

import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.bbjob.model.User;

public class JwtUser implements UserDetails{
	private Integer id;
    private String username;
    private String password;
    private Integer oriCode;
    private String realname;
    private Integer type;
    public Integer getOriCode() {
		return oriCode;
	}

	public void setOriCode(Integer oriCode) {
		this.oriCode = oriCode;
	}
	private Collection<? extends GrantedAuthority> authorities;
    public JwtUser(User user,Collection<? extends GrantedAuthority> authorities) {
        id = user.getId();
        username = user.getUsername();
        password = user.getPassword();
        realname = user.getRealname();
        type = user.getType();
        this.oriCode=user.getOrganId();
        this.authorities=authorities;
    }

	@Override
	public Collection<? extends GrantedAuthority> getAuthorities() {
		// TODO Auto-generated method stub
		return authorities;
	}
	public Integer getId() {
		return this.id;
	}

	@Override
	public String getPassword() {
		// TODO Auto-generated method stub
		return this.password;
	}

	@Override
	public String getUsername() {
		// TODO Auto-generated method stub
		return this.username;
	}

	public String getRealname() {
		// TODO Auto-generated method stub
		return this.realname;
	}
	
	public Integer getType() {
		// TODO Auto-generated method stub
		return this.type;
	}
	
	@Override
	public boolean isAccountNonExpired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isAccountNonLocked() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isCredentialsNonExpired() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean isEnabled() {
		// TODO Auto-generated method stub
		return true;
	}
	 @Override
	    public String toString() {
	        return "JwtUser{" +
	                "id=" + id +
	                ", username='" + username + '\'' +
	                ", password='" + password + '\'' +
	                ", authorities=" + authorities +
	                '}';
	    }
	
}
